import Home from '@/views/Home'
import Search from '@/views/Search'
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter) // VueRouter插件初始化

// 创建了一个路由对象
/*
声明式导航 - 跳转传参
目标:在跳转路由时，进行传值

2.动态路由传参
 (1) 配置动态路由
  const router = new VueRouter({
    routes:[
      ...
      {
        //加问号的作用
        path:'/search/:words', component: Search
      }
    ]
  })
 (2) 配置导航链接
    to="/path/参数值"  
 (3) 对应页面组件接收传递过来的值
    $route.params.参数名   
*/
const router = new VueRouter({
  routes: [
    { path: '/home', component: Home },
    { path: '/search/:key?', component: Search }
  ]
})

export default router